package com.andnnl.http;

import cn.hutool.http.HttpRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Created by chenss on 2021/9/18.
 */
public class UrlTest {
    static Logger logger = LoggerFactory.getLogger(UrlTest.class);

    public static void main(String[] args) {
        getUrl();

    }

    /**
     * 同步方法，获取代理Bean
     *
     * @return
     */
    public static String getUrl() {
//        String url = "http://192.168.4.124:8010"+ "/getNextIpBean";
//        String url = "http://www.3daili.top:9091/Api_1g/?order=5bb7e99365a6edd3ab9f5805fdda88e0&jg=1&num=10&lx=A&proxy=http&gs=gs_json";
        String url = "http://139.196.219.28:2021/Tools/proxyIP.ashx?action=GetIPAPI&OrderNumber=331a1a0ed1c99cc16f65988ee104607b&qty=3";
        try {
            String result = HttpRequest.get(url)
                    .setConnectionTimeout(5000)
                    .setReadTimeout(5000)
//                .contentType("getUrl")

//                .header(Header.ACCEPT,"text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9")
//                    .header(Header.CONTENT_TYPE,"text/plain; charset=utf-8")
//                    .header(Header.HOST,"www.3daili.top:9091")
//                    .header(Header.USER_AGENT,"Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.106 Safari/537.36 88250860")
                    .setFollowRedirects(true)
                    .execute().body();

//            String result =HttpHelper.get(url);

            System.out.println("url:" + url + " rs:" + result);
            if(result==null)return null;
        } catch (Exception e) {
//            e.printStackTrace();
        }
        return null;
    }


}
